<?php

namespace app\api\controller;

use app\api\model\Order;
use app\api\model\ScoreShop;
use app\api\model\User;
use app\api\service\Pay as ServicePay;

class Pay extends Base
{
    public function list()
    {
        $list = ScoreShop::where(['status' => 1])->select();
        $user = User::field('score')->find($this->uid);
        return success(['list' => $list, 'user' => $user]);
    }
    public function initOrder()
    {
        $res = (new ServicePay())->initOrder();
        return success($res);
    }
    public function notifyUrl()
    {
        return (new ServicePay())->notifyUrl();
    }
    public function returnUrl()
    {
        $res = (new ServicePay())->returnUrl();
        if ($res['code'] == 200) return view('common/success', ['data' => ['msg' => $res['msg']]]);
        return error('common/error', ['data' => ['msg' => $res['msg']]]);
    }
}
